﻿/*
 * Created by SharpDevelop.
 * User: StrunevskyDV
 * Date: 02.03.2010
 * Time: 10:05
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.ComponentModel;
using EmailJabber.Entities.Entities;
using FinancialPersonal.Base;

namespace FinancialPersonal.Entities
{
	/// <summary>
	/// Description of EnvelopeEntity.
	/// </summary>
	public class GoalEntity:EntityBase
	{
		public GoalEntity()
		{
			Id = Guid.NewGuid();
		}
		public bool Active{get;set;}
		public Guid UserId{get;set;}
		
		public string Description{get;set;}
		public DateTime BeginCollect{get;set;}
		public DateTime EndCollect{get;set;}
		public DateTime LastGoalChanged{get;set;}
		public decimal Cost{get;set;}
		
		[TypeConverter(typeof(DecimalTypeConverter))]
		[Description("Денег откладывать каждый месяц")] 
		public decimal MoneyPerMonth
		{
			get
			{
				if(!Active)return 0;
				double days=monthDifference(EndCollect,BeginCollect);
				           if(days>0)
				           {
				           	return Cost / (decimal)days ;
				           }
				           else
				           {
				           	return 0;
				           }
			}
		}
		public decimal MoneyNow
		{
			get
			{
				if(!Active)return 0;
				
				return (MoneyPerMonth * monthDifference(DateTime.Now,BeginCollect));
			}
		}
		
	}
}
